// pages/Main/mainIndex/mainIndex.js
var businessLogic = require('../../../utils/NetWork/Model/LoginbusinessLogic.js')
var common = require('../../../utils/common.js')
var countdown = 60;
var settime = function (that) {
  if (countdown == 0) {
    that.setData({
      is_show: true
    })
    countdown = 60;
    return;
  } else {
    that.setData({
      is_show: false,
      last_time: countdown
    })

    countdown--;
  }
  setTimeout(function () {
    settime(that)
  }
    , 1000)
}
Page({

  /**
   * 页面的初始数据
   */
  data: {
    phone: "",
    yzm: "",
    mima1: "",
    mima2: "",
    last_time: '',
    is_show: true
  }, phone: function (e) {
    this.setData({
      phone: e.detail.value
    })
  }, yzm: function (e) {
    this.setData({
      yzm: e.detail.value
    })
  }, mima1: function (e) {
    this.setData({
      mima1: e.detail.value
    })
  }, mima2: function (e) {
    this.setData({
      mima2: e.detail.value
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  }, clickVerify: function () {
    if (this.data.phone == undefined || this.data.phone == "") {
      common.showToast("请输入手机号", "none")
    } else if (!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(this.data.phone))) {
      common.showToast("不是完整的11位手机号或者正确的手机号前七位", "none");
    } else {
      var that = this;
      // 将获取验证码按钮隐藏60s，60s后再次显示
      that.setData({
        is_show: (!that.data.is_show)  //false
      })
      console.log(this.data.is_show);
      settime(that);
    } 

  }, login: function (e) {
    if (this.data.phone == undefined || this.data.phone == "") {
      common.showToast("请输入手机号", "none")
    } else if (!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(this.data.phone))) {
      common.showToast("手机号不正确", "none");
    } else if (this.data.yzm == undefined || this.data.yzm == "") {
      common.showToast("请输入验证码", "none")
    } else if (this.data.mima1 == "" || this.data.mima1 == "") {
      common.showToast("密码不能为空", "none");
    } else if (this.data.mima1 != this.data.mima2) {
      common.showToast("密码不能不一致", "none");
    } else {
      wx.reLaunch({
        url: '../../Login/logining/logining',
      })
    }

  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})